﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using ThaoTac;
using ThongTin;
using DuLieu;

namespace GiaoDien
{
    public partial class frmDanhSachHeDaoTao : Form
    {
        HeDaoTao_DL dt = new HeDaoTao_DL();
        public frmDanhSachHeDaoTao()
        {
            InitializeComponent();
            tblDanhSachheDaoTao.DataSource = dt.DanhSachHeDaoTao();
        }
        public void add(Object sender, EventArgs e)
        {
            frmQuanLyHeDaoTao tt = (frmQuanLyHeDaoTao)sender;
            DataTable dt = (DataTable)tblDanhSachheDaoTao.DataSource;
            dt.Rows.Add(tt.MaHe, tt.TenHe);
            tblDanhSachheDaoTao.DataSource = dt;

            SqlConnection cnn = new SqlConnection();
            SqlCommand cmd = new SqlCommand("ThemKhoa", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            SqlCommandBuilder cmb = new SqlCommandBuilder(da);
            da.UpdateCommand = cmb.GetUpdateCommand();
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            frmQuanLyHeDaoTao tt = new frmQuanLyHeDaoTao();
            tt.addNew += new EventHandler(add);
            tt.ShowDialog();
        }
    }
}
